//
//  FindTableViewCell.m
//  Shine
//
//  Created by 王斌 on 16/3/16.
//  Copyright © 2016年 王斌. All rights reserved.
//

#import "FindTableViewCell.h"

@implementation FindTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.picImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.picImageView];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textColor = COLORWHITE;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.titleLabel];

    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    

    
    self.picImageView.frame = CGRectMake(10, 10, 130, 150);
    
    
    // 计算label高度
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.font = [UIFont systemFontOfSize:17];
    
    NSString *str = self.titleLabel.text;
    // 计算文字的高度
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17], NSFontAttributeName, nil];
    // 根据文本的内容和文本的字体进行计算高度
    // 参数1:告诉系统,文本显示的最大范围
    CGRect rect = [str boundingRectWithSize:CGSizeMake(self.contentView.frame.size.width - 160, 0) options: NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    // 对label进行尺寸设置
    self.titleLabel.frame = CGRectMake(150, 20, self.contentView.frame.size.width - 160, rect.size.height);
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
